﻿using System;
using System.Collections.Generic;

namespace Equinoxe.EZNFC.Library
{
    /// <summary>
    /// The interface for an NFC device
    /// </summary>
    /// <remarks></remarks>
    public interface INFCDevice : IDisposable
    {
        /// <summary>
        /// Occurs when a tag is detected.
        /// </summary>
        /// <remarks></remarks>
        event Events.NFCTagEventHandler TagDetected;

        /// <summary>
        /// Observable tag collection.
        /// </summary>
        /// <remarks></remarks>
        ObservableTagCollection TagCollection { get; }
        // info
        /// <summary>
        /// Gets the device info.
        /// </summary>
        /// <remarks></remarks>
        NFCDeviceInfo DeviceInfo { get; }

        /// <summary>
        /// Gets the bauds.
        /// </summary>
        /// <remarks></remarks>
        int Bauds { get; }
        /// <summary>
        /// Gets the charset.
        /// </summary>
        /// <remarks></remarks>
        DeviceCharset Charset { get; }
        /// <summary>
        /// Gets the port.
        /// </summary>
        /// <remarks></remarks>
        Ports Port { get; }
        /// <summary>
        /// Opens this instance.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        void Open();

        /// <summary>
        /// Opens this instance asynchronously.
        /// </summary>
        /// <param name="callback">The callback.</param>
        /// <param name="exceptionCallback">The exception callback.</param>
        /// <remarks></remarks>
        void OpenAsync(Action callback, Action<Exception> exceptionCallback);
        /// <summary>
        /// Closes this instance.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        void Close();

        /// <summary>
        /// Gets the port.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        string GetPort();
        /// <summary>
        /// Gets the firmware.
        /// </summary>
        /// <param name="slot">The slot.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        string GetFirmware(int slot = 0);

        /// <summary>
        /// Displays the LCD message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="row">The row.</param>
        /// <param name="col">The col.</param>
        /// <remarks></remarks>
        void DisplayLCDMessage(string message, int row = 0, int col = 0);


        /// <summary>
        /// Displays the LCD image.
        /// </summary>
        /// <param name="imagepath">The path of the image.</param>
        /// <remarks></remarks>
        void DisplayLCDImage(string imagepath);
        /// <summary>
        /// Set the backlight.
        /// </summary>
        /// <param name="lcdon">if set to <c>true</c> [on].</param>
        /// <remarks></remarks>
        void LCDBacklight(bool lcdon);


        /// <summary>
        /// Set the LCD contrast.
        /// </summary>
        /// <param name="contrast">The contrast level.</param>
        /// <remarks></remarks>
        void LCDContrast(int contrast);

        /// <summary>
        /// Clear LCD screen.
        /// </summary>
        /// <remarks></remarks>
        void LCDClear();

        /// <summary>
        /// Scroll LCD.
        /// </summary>
        /// <param name="speed">The speed.</param>
        /// <param name="scrollDirection">The scroll direction.</param>
        /// <remarks></remarks>
        void LCDScroll(LCDSCrollSpeed speed = LCDSCrollSpeed.Medium, LCDScrollDirection scrollDirection = LCDScrollDirection.LeftToRight);


        /// <summary>
        /// Pause the LCD scroll.
        /// </summary>
        /// <remarks></remarks>
        void LCDPauseScroll();

        /// <summary>
        /// Stop the LCD scroll.
        /// </summary>
        /// <remarks></remarks>
        void LCDStopScroll();

        /// <summary>
        /// Buzzers.
        /// </summary>
        /// <param name="ontime">The on time.</param>
        /// <param name="offtime">The off time.</param>
        /// <param name="numberoftimes">The number of times to repeat.</param>
        /// <remarks></remarks>
        void Buzzer(int ontime, int offtime, int numberoftimes);

        /// <summary>
        /// Sets a LED.
        /// </summary>
        /// <param name="number">The LED number.</param>
        /// <param name="state">if set to <c>true</c> [on].</param>
        /// <remarks></remarks>
        void SetLED(int number, bool state);

        /// <summary>
        /// Sets the LEDS.
        /// </summary>
        /// <param name="states">IEnumerable with state of each LED.</param>
        /// <remarks></remarks>
        void SetLEDS(IEnumerable<bool> states);

        // Polling
        /// <summary>
        /// Gets a value indicating whether this instance is poling.
        /// </summary>
        /// <remarks></remarks>
        bool IsPoling { get; }
        /// <summary>
        /// Starts the polling.
        /// </summary>
        /// <remarks></remarks>
        void StartPolling();
        /// <summary>
        /// Stops the polling.
        /// </summary>
        /// <remarks></remarks>
        void StopPolling();
        /// <summary>
        /// Gets or sets the polling interval.
        /// </summary>
        /// <value>The polling interval.</value>
        /// <remarks></remarks>
        int PollingInterval { get; set; }

        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name="sendbuffer">The sendbuffer.</param>
        /// <param name="sendbufferlength">The sendbufferlength.</param>
        /// <param name="receivebuffer">The receivebuffer.</param>
        /// <param name="receivebufferlength">The receivebufferlength.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        void SendMessage(byte[] sendbuffer, int sendbufferlength, byte[] receivebuffer, ref int receivebufferlength);
    }
}
